<template>
  <view class="page">
    <!-- 背景图片 -->
    <image
        src="/static/bj-001.jpg"
        mode="cover"
        class="bg-image"
    ></image>
    <view class="content">
      <view v-if="iview" class="action-item" @click="handleIndex('upload')">
        <text class="action-text">作品上传</text>
        <image
            class="action-image" style="width: 400rpx;height: 40rpx;"
            mode="widthFix"
            src="/static/images/upload.png"
        ></image>
      </view>
      <view v-if="iview" class="action-item" @click="handleIndex('edit')">
        <text class="action-text">信息修改</text>
        <image
            class="action-image" style="width: 400rpx;height: 40rpx;"
            mode="widthFix"
            src="/static/images/edit.png"
        ></image>
      </view>
      <view v-if="!iview" class="action-item" @click="handleIndex('query')">
        <text class="action-text">查询结果</text>
        <image
            class="action-image" style="width: 400rpx;height: 40rpx;"
            mode="widthFix"
            src="/static/images/query.png"
        ></image>
      </view>
      <view class="action-item" @click="handleIndex('rule')">
        <text class="action-text">活动规则</text>
        <image
            class="action-image" style="width: 400rpx;height: 40rpx;"
            mode="widthFix"
            src="/static/images/rule.png"
        ></image>
      </view>
    </view>
  </view>
</template>

<script>
import {getProActivity} from "@/api/activity/activity";

export default {
  data() {
    return {
      iview: false,
      activityId: ""
    };
  },
  onLoad() {
    getProActivity().then(res => {
      if (res.code === 200) {
        if (res.data && res.data.id) {
          this.iview = true;
        }
      }

    })
  },
  mounted() {
    this.getUrlParams()
  },
  methods: {
    handleIndex(type) {
      const pageMap = {
        'upload': `/pages/saishi/upload?activityId=${encodeURIComponent(this.activityId)}`,
        'edit': '/pages/saishi/edit',
        'query': '/pages/saishi/queryCj',
        'rule': '/pages/saishi/rule'
      };
      uni.navigateTo({
        url: pageMap[type]
      });
    },
    // 新增方法：获取URL参数
    getUrlParams() {
      const pages = getCurrentPages()
      const currentPage = pages[pages.length - 1]
      const options = currentPage.options

      if (options.activityId) {
        this.activityId = decodeURIComponent(options.activityId)
      }
    },
  }
};
</script>

<style lang="scss">
@font-face {
  font-family: 'minikt';
  src: url('@/static/font/minikt.TTF') format('truetype');
}

.page {
  position: relative;
  width: 100%;
  height: 100vh;
}

.bg-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.8;
}

.content {
  position: relative;
  z-index: 1;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background-color: transparent; /* 设置背景为透明 */
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  padding-top: 200rpx;
  margin-top: 100rpx;
}

.action-item {
  position: relative;
  margin-bottom: 10px; /* 将 margin-bottom 从 20px 调整为 10px */
  text-align: center;
}

.action-text {
  position: absolute;
  color: #004AAC;
  font-size: 40rpx;
  font-weight: bold;
  font-family: 'minikt', sans-serif;
  top: 50%;
  left: 50%;
  width: 100%;
  margin-left: 25rpx; /* 将 margin-top 从 -40rpx 调整为 -30rpx */
  transform: translate(-50%, -50%);
  z-index: 2;
}

.action-image {
  position: relative;
  z-index: 1;
}

.signup-container {
  position: relative;
  text-align: center;
  margin-top: 20px;
}


</style>